<template>
    <div>
        <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">

        </el-col>

        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="名称">
                <el-input v-model="form.title"></el-input>
            </el-form-item>
            <el-form-item label="分类">
                <el-select v-model="form.cate" placeholder="请选择分类">
                    <el-option label="wen zhang" value="1" checked></el-option>
                    <el-option label="tu pian" value="2"></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="keywords">
                <el-input v-model="form.keywords"></el-input>
            </el-form-item>
            <el-form-item label="desc">
                <el-input type="textarea" v-model="form.desc"></el-input>
            </el-form-item>
            <el-form-item label="文章内容">
                <QuillEditor></QuillEditor>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import QuillEditor from '../../components/QuillEditor/QuillEditor.vue'
    import { addArticle } from '../../api/api'

    export default {
        data() {
            return {
                form: {
                    title: '',
                    cate: '',
                    keywords: '',
                    desc: '',
                    content: '',
                }
            }
        },
        components: {
            QuillEditor
        },
        methods: {
            getContent () {
                this.form.content = this.$store.state.content
                console.log(this.form.content)
            },
            onSubmit() {
                console.log('submit!');
                console.log(this.form)
                this.form.content = this.$store.state.content
                addArticle(this.form).then((res) => {
                    console.log(res);
                },(err) => {
                    console.log(err)
                })
            }
        }
    }
</script>